import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

/*
 *  Picture.java - A class that enables the employees to add 
 *  			profile pictures to their profile pages.
 * 
 *  @Author : BilCIS
 */

public class Picture 
{
	// properties
	private static final int IMG_WIDTH = 100;
	private static final int IMG_HEIGHT = 100;
	
	private int type;
	
	private BufferedImage originalImage;
	private	BufferedImage resizedImage;
	
	// constructor
	public Picture(BufferedImage originalImage, int type)
	{
		this.originalImage = originalImage;
		this.type = type;
	}
	
	// A method that resizes the chosen picture in order to make it fitin the space provided.
    public BufferedImage resizeImage()
    {
		resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
		Graphics2D g = resizedImage.createGraphics();
		g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
		g.dispose();

		return resizedImage;
    }
    
    // A method that saves the profile picture to the hard-disk.
    public void writeImage( String path ) throws IOException
    {
    	ImageIO.write(resizedImage, "png", new File( path ) );
    }

}
